import React from 'react'

function Hooks01(props) {
    return (<>
    <button onClick={() => props.douber}>x2</button>
    <div>第一个函数组件：{props.timer}</div>
    
    
    </>
    )
}
export default class Function extends React.Component {

    state = {
        timer: 0,
    };
    timer;
    componentDidMount() {
        this.timer = setInterval(() => {
            const newTimer = this.state.timer;
            this.setState({ timer: newTimer + 1 })
            
        }, 1000);
    }
    componentWillUnmount() {
        clearInterval(this.timer);
    }
    douber=() => {
        //  this.state.timer * 2;
    }
    render() {

        return (
            <Hooks01 timer={this.state.timer} douber = {this.douber}/>
        )
    }
}




